home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’95 / Menu Controls / UShapeList.h < prev    next >
Encoding:
Text File  |  1995-06-24  |  1.9 KB  |  75 lines  |  [TEXT/MPS ]

  1. // Copyright © 1994-95 by Apple Computer, Inc. All rights reserved.
  2. // UShapeList.h
  3.  
  4. #ifndef __USHAPELIST__
  5. #define __USHAPELIST__
  6.  
  7. #ifndef __USHAPES__
  8. #include "UShapes.h"
  9. #endif
  10.  
  11. #ifndef __ULIST__
  12. #include <UList.h>
  13. #endif
  14.  
  15. #ifndef __ULISTITERATOR__
  16. #include <UListIterator.h>
  17. #endif
  18.  
  19. //--------------------------------------------------------------------------------------------------
  20. // Function types for TShapeList iteration
  21.  
  22. typedef void(* DoToShapeType)(TShape* item, void* staticLink);
  23.  
  24. typedef Boolean (*TestShapeType)(TShape* item, void* staticLink);
  25.  
  26. //--------------------------------------------------------------------------------------------------
  27. // Shape List class
  28. //----------------------------------------------------------------------------------------
  29. class TShapeList : public TList
  30. {
  31.     MA_DECLARE_CLASS;
  32.     
  33.   public:
  34.     TShapeList();    // Obligatory Constructor
  35.  
  36.     TShape* ShapeAt(ArrayIndex index);
  37.  
  38.     void Each(DoToShapeType DoToShape, void* staticLink);
  39.  
  40.     TShape* FirstThat(TestShapeType TestShape, void* staticLink);
  41.  
  42.     virtual TShape* IterateTil(TestShapeType TestShape,
  43.                                void* staticLink,
  44.                                Boolean IterateForward,
  45.                                ArrayIndex& itsIndex);
  46. };
  47.  
  48. //--------------------------------------------------------------------------------------------------
  49. // Shape Iterator class
  50. //--------------------------------------------------------------------------------------------------
  51. class CShapeIterator : public CArrayIterator
  52. {
  53.   public:
  54.     CShapeIterator (TShapeList* itsList,
  55.                     ArrayIndex itsLowBound,
  56.                     ArrayIndex itsHighBound,
  57.                     Boolean itsForward);
  58.  
  59.     CShapeIterator(TShapeList* itsList, Boolean itsForward = kIterateForward);
  60.  
  61.     virtual ~CShapeIterator();
  62.     
  63.     TShape* CurrentShape();
  64.         // Returns the current shape
  65.     
  66.     TShape* FirstShape();
  67.         // Resets the iteration and returns the first shape in the iteration
  68.  
  69.     TShape* NextShape();
  70.         // Advances the iteration and then returns the shape
  71. };
  72.  
  73.  
  74. #endif
  75.